package com.powernode;

import java.util.Scanner;

/**
 * description 暂无描述
 * author smile
 * time 2023/3/13 10:29
 */
public class Test1 {
    public static void main(String[] args) {
        String [] name=new String[1000];
        name[0]="王培";
        name[1]="张森";
        name[2]="章加薪";
        name[3]="白薇";
        name[4]="张威";
        name[5]="洪瑞";
        name[6]="徐诗瑶";
        String [] idCard=new  String[1000];
        idCard[0]="420111111111111111";
        idCard[1]="420222222222222222";
        idCard[2]="420333333333333333";
        idCard[3]="420444444444444444";
        idCard[4]="420555555555555555";
        idCard[5]="420666666666666666";
        idCard[6]="420777777777777777";
        int  [] gender=new  int[1000];
        gender[0]=1;
        gender[1]=1;
        gender[2]=1;
        gender[3]=1;
        gender[4]=1;
        gender[5]=1;
        gender[6]=0;
        String [] address=new  String[1000];
        address[0]="地球村中国";
        address[1]="中国武汉";
        address[2]="中国武汉";
        address[3]="中国武汉";
        address[4]="中国武汉";
        address[5]="中国武汉";
        address[6]="中国武汉";
        int index=7;
        for (;;) {
            System.out.println("********请输入如下选项********");
            System.out.println("        1.信息录入           ");
            System.out.println("        2.信息查询           ");
            System.out.println("        3.信息修改           ");
            System.out.println("        4.信息删除           ");
            System.out.println("        5.退出           ");
            Scanner input=new Scanner(System.in);
            System.out.print("请输入您要选择的选项：");
            int num= input.nextInt();
            switch (num) {
                case 1:
                    System.out.println("开始录入公民信息：");
                    System.out.print("请输入姓名：");
                    name[index]= input.next();
                    System.out.print("请输入身份证号码：");
                    idCard[index]=input.next();
                    System.out.print("请输入性别(1男,0女)：");
                    gender[index]= input.nextInt();
                    System.out.print("请输入地址：");
                    address[index]=input.next();
                    System.out.println("录入成功！！！");
                    index++;
                    break;
                case 2:
                    System.out.println("所有人信息列表如下:");
                    for (int j = 0; j< index; j++) {
                        if (name[j]==null) {
                            continue;
                        }else {
                            System.out.print(name[j]+"  "+idCard[j]+"  ");
                        }
                        if (gender[j]==0){
                            System.out.print("女");
                        }else if(gender[index]==1) {
                            System.out.print("男");
                        }
                        System.out.print("  "+address[j]);

                        System.out.println();
                    }

                    break;
                case 3:
                    System.out.println("信息修改:");
                    System.out.print("请输入需要修改人身份证：");
                    String num1= input.next();
                    boolean flag = false;
                    for (int j = 0; j < index; j++) {
                        if (num1.equals(idCard[j])) {
                            flag = true;
                        }
                        if (flag){ System.out.print("开始信息修改：");
                            String idCard1 = input.next();
                            System.out.print("请输入姓名：");
                            String name1 = input.next();
                            System.out.println("请输入性别：");
                            int gender1 = input.nextInt();
                            System.out.println("请输入地址：");
                            String address1 = input.next();
                            System.out.println("信息修改成功！！！");
                            break;
                        }

                        System.out.println("您输入的身份证号不存在！！！");


                        break;
                    }
                case 4:
                    System.out.println("开始信息删除：");
                    System.out.print("请输入要删除的身份证号：");
                    String num2= input.next();
                    boolean flag1 = false;
                    for (int j = 0; j < index; j++) {
                        if (num2.equals(idCard[j])) {
                            flag1 = true;
                        }
                    }
                    if (flag1) {
                        idCard[index]=null;
                        name[index]=null;
                        gender[index]=0;
                        address[index]=null;
                        System.out.println("删除成功！！！");
                    }
                    break;
                case 5:
                    System.exit(0);
                    break;
                default:
                    System.out.println("您输入的信息有误！");
                    break;

            }
            System.out.println();
        }
    }
}
